package com.pyue.eam.regi.controller;

import cn.hutool.core.collection.CollUtil;
import com.pyue.eam.admin.api.dto.chart.ChartData;
import com.pyue.eam.common.core.util.R;
import com.pyue.eam.common.security.annotation.Inner;
import com.pyue.eam.regi.service.CqTaskLibService;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/chartData")
@Tag(description = "chartData", name = "图表数据管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ChartDataController {
    private final CqTaskLibService cqTaskLibService;

    /**
     * 进度图
     */
    @Inner(value = false)
    @GetMapping("arcbarData")
    public R<ChartData> arcbarData() {
        return R.ok(ChartData.builder().series(cqTaskLibService.arcbarData()).build());
    }

    /**
     * 柱状图
     */
    @Inner(value = false)
    @GetMapping("columnData")
    public R<ChartData> columnData() {
        // 获取当前过去六个月的年月值
        return R.ok(cqTaskLibService.columnData(6));
    }

    /**
     * 累加对比图
     */
    /* @Inner(value = false)
    @GetMapping("sumCompareData")
    public R<ChartData> sumCompareData() {
        ChartData chartData = new ChartData();
        chartData.setCategories(CollUtil.toList("2018", "2019", "2020", "2021", "2022", "2023"));
        chartData.setSeries(CollUtil.newArrayList(new ChartSeries("目标值", CollUtil.toList(35, 36, 31, 33, 13, 34)),
                new ChartSeries("完成量", CollUtil.toList(18, 27, 21, 24, 6, 28))));

        return R.ok(chartData);
    } */

    /**
     * 饼图
     */
    /* @Inner(value = false)
    @GetMapping("pieData")
    public R<ChartData> pieData() {
        List<ChartSeries> chartSeries = CollUtil.newArrayList(ChartSeries.builder().name("完成").data(50).build(),
                ChartSeries.builder().name("进行中").data(30).build(), ChartSeries.builder().name("超时").data(30).build());

        return R.ok(ChartData.builder().series(chartSeries).build());
    } */

    /**
     * 图表信息提示
     */
    @Inner(value = false)
    @GetMapping("chartNotice")
    public R<List<String>> chartNotice() {
        return R.ok(CollUtil.newArrayList("团表统计有三个小时延时,后续会改成实时数据...", "每周坚持更新两个版本，敬请期待..."));
    }

}
